import React from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { changeAge } from '../../store/actions/user'

export default function User() {
  const dispatch = useDispatch()
  const user = useSelector((state) => state.user)
  return (
    <div>
      <h3>{user.age}</h3>
      <button onClick={() => dispatch({ type: 'CHANGE_AGE', payload: 100 })}>
        修改 age
      </button>
      <button onClick={() => dispatch(changeAge(100))}>修改 age</button>
    </div>
  )
}
